{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f9fa3e07",
   "metadata": {},
   "source": [
    "-----------\n",
    "* 2022-8-30\n",
    "* python学习第二周\n",
    "* 记录人：张文鑫\n",
    "-------------\n",
    "\n",
    "# 本周学习内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "07a62286",
   "metadata": {},
   "source": [
    "## 1.P4\n",
    "> 一定要按规格写以下代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a3822dc7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45,\n",
    "       47, 49, 51, 53, 55, 57, 59]\n",
    "\n",
    "right_this_minute = datetime.today( ) .minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c7dcab1d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "712280\n",
      "Not an odd minute.\n",
      "713280\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45,\n",
    "       47, 49, 51, 53, 55, 57, 59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n",
    "    print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d11a2e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 判断当前是一周中的星期几，如果是星期二，然后打印python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d4e71313",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e528039a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "6999fe2a",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (3515602266.py, line 5)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [22]\u001b[1;36m\u001b[0m\n\u001b[1;33m    print(\"今天有python课，哈哈哈哈哈哈哈哈哈，太开心了！时间为：下午2：30-4：50\")\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "# tm_wday: 0-6 0是星期一\n",
    "今天 = time.localtime().tm_wday\n",
    "\n",
    "if 今天 == 1:\n",
    "print(\"今天有python课，哈哈哈哈哈哈哈哈哈，太开心了！时间为：下午2：30-4：50\")\n",
    "else:\n",
    "    print(\"今天没有python课\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "3ae361d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "2fe4b035",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (1793971405.py, line 8)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [27]\u001b[1;36m\u001b[0m\n\u001b[1;33m    print(\"非python课时间\")\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "time.localtime().tm_hour  # 是不是在14到16之间  如果是14  再看看tm_minute  是不是在0-30  如果是16的话，再看tm_minute是不是在50以上\n",
    "此时 = time.localtime().tm_hour\n",
    "\n",
    "if 此时 == 14:\n",
    "    print(\"time.localtime().tm_minute\")\n",
    "\n",
    "else:\n",
    "print(\"非python课时间\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f2347b7",
   "metadata": {},
   "source": [
    "## 2.模块--标准库\n",
    "* 标准库是python开发团队满足用户日常需求而写好的一些模块，可以直接使用：import 模块名称"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69fa65d3",
   "metadata": {},
   "source": [
    "> 1.sys模块\n",
    "\n",
    "> 2.os模块\n",
    "\n",
    "> 3.datetime模块\n",
    "\n",
    "## 2.2 模块-开源模块 (pypi.org)\n",
    "### 2.3 自定义模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2c144db5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3e0a40c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1ad41fd6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8f3b4767",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\大二1\\\\python\\\\week02'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3a1aa9f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3b1c7c38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 8, 30)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a7c1d0f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 认识下time模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3f0e8be8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "49fe0e4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=14, tm_min=29, tm_sec=31, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "5cea730e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1661841019.273242"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time() # 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "96500424",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "52.696637708896844"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()/60/60/24/365"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "14959e50",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1970"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2022-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d1de8a14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=6, tm_min=33, tm_sec=24, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "3c587c5d",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'apple'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [19]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mapple\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'apple'"
     ]
    }
   ],
   "source": [
    "import apple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a08c64ad",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'datetime' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [21]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mdatetime\u001b[49m\u001b[38;5;241m.\u001b[39mdatetime\u001b[38;5;241m.\u001b[39mtoday()\u001b[38;5;241m.\u001b[39mmicrosecond\n",
      "\u001b[1;31mNameError\u001b[0m: name 'datetime' is not defined"
     ]
    }
   ],
   "source": [
    "datetime.datetime.today().microsecond"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5cc27d70",
   "metadata": {},
   "source": [
    "## 3.赋值\n",
    "\n",
    "## 4.变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "4c0035fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "wait_time = 26\n",
    "waitTime = 34\n",
    "gf_of_liu = \"Lucy\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "81f505f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wait_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15513a2d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
